import { getMusicLyric } from '@/request/api/item';
import { createStore } from 'vuex'

export default createStore({
  state: {
    playList: [{ //播放列表默认值
      al: {
        id: 142044506,
        name: "晚风心里吹",
        pic: 109951167297344640,
        picUrl: "https://p1.music.126.net/3w-ekH3z77-HvqOJ3fCPVw==/109951167297344637.jpg",
        pic_str: "109951167297344637"
      },
      id: 1929370102,
      name: "阿梨粤"

    }],
    playListIndex: 0, //默认的下标为0
    isbtnShow: true,//暂停按钮显示
    detailShow: false,//歌曲详情页显示
    lyricList: {},//歌词
    currentTime: 0, //当前时间
    duration:0, //歌曲总时长
  },
  getters: {
  },
  mutations: {
    updateisbtnShow: function (state, value) {
      state.isbtnShow = value
    },
    updatePlayList: function (state, value) {
      state.playList = value
      // console.log(state.playList);
    },
    updatePlayListIndex: function (state, value) {
      state.playListIndex = value
      console.log(state.playListIndex);
    },
    updateDetailShow: function (state) {
      state.detailShow = !state.detailShow
    },
    updateLyricList: function (state, value) {
      state.lyricList = value
    },
    updateCurrentTime: function (state, value) {
      // console.log(state.currentTime);
      state.currentTime = value
    },
    updateDuration:function(state,value) {

      state.duration = value

    }
  },
  actions: {
    getLyric: async function (context, value) {
      let res = await getMusicLyric(value)
      console.log(res);
      context.commit("updateLyricList", res.data.lrc)
    }
  },
  modules: {
  }
})
